'''
Created on Jan 10, 2013

@author: trananh
'''

class Forest(object):
    """
    Implements a forest (i.e., a collection of trees).
    """

    def __init__(self):
        """
        Constructs a new forest
        """
        self.counter = 0
        self.trees = dict()
    
    def __genID(self):
        """
        Generates a new unique ID.
        """
        self.counter += 1
        return self.counter
    
    def add(self, tree):
        """
        Adds a new tree to the forest
        
        PARAMETERS:
            tree - New tree to be added.
        """
        treeName = self.__genID() if tree.name is None else tree.name
        self.trees[treeName] = tree
    
    def getTrees(self):
        """
        Returns a list of trees in the forest.
        """
        return self.trees.values()
